#include <iostream>
using namespace std;
struct Node
{
    int N;
    double a;
    Node *next;
};
int main()
{
    Node nodes1[15], nodes2[15];
    int n, m;
    int i, j;
    cin >> n;
    for (i = 0; i < n; i++)
    {
        cin >> nodes1[i].N;
        cin >> nodes1[i].a;
    }
    cin >> m;
    for (i = 0; i < m; i++)
    {
        cin >> nodes2[i].N;
        cin >> nodes2[i].a;
    }
    Node *n3, *p, *t, *pre;
    int count = 0;
    n3 = new Node();
    n3->next = NULL;
    for (i = 0; i < n; i++)
    {
        for (j = 0; j < m; j++)
        {
            p = new Node();
            p->N = nodes1[i].N + nodes2[j].N;
            p->a = nodes1[i].a * nodes2[j].a;
            p->next = NULL;
            if (p->a != 0)
            {
                //找到插入位置
                t = n3->next;
                pre = n3;
                while (t != NULL)
                {
                    if (t->N == p->N)
                    {
                        t->a += p->a;
                        if (t->a == 0)
                        {
                            pre->next = t->next;
                            count--;
                        }
                        break;
                    }
                    else if (t->N > p->N)
                    {
                        pre = t;
                        t = t->next;
                    }
                    else
                    {
                        pre->next = p;
                        p->next = t;
                        count ++;
                        break;
                    }
                }
                if (t == NULL)
                {
                    pre->next = p;
                    count ++;
                }
            }
        }
    }
    cout << count;
    t = n3->next;
    for (i = 0; i < count; i++)
    {
        printf(" %d %.1f",t->N,t->a);
        t = t->next;
    }
    return 0;
}